home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / text / rtf / RTFReader$StylesheetDestination$StyleDefiningDestination.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  3.9 KB  |  133 lines

  1. package javax.swing.text.rtf;
  2.  
  3. import javax.swing.text.Style;
  4. import javax.swing.text.rtf.RTFReader.StylesheetDestination;
  5.  
  6. class RTFReader$StylesheetDestination$StyleDefiningDestination extends RTFReader.AttributeTrackingDestination implements RTFReader.Destination {
  7.    // $FF: synthetic field
  8.    private final RTFReader.StylesheetDestination this$1;
  9.    final int STYLENUMBER_NONE;
  10.    boolean additive;
  11.    boolean characterStyle;
  12.    boolean sectionStyle;
  13.    public String styleName;
  14.    public int number;
  15.    int basedOn;
  16.    int nextStyle;
  17.    boolean hidden;
  18.    Style realizedStyle;
  19.  
  20.    public RTFReader$StylesheetDestination$StyleDefiningDestination(RTFReader.StylesheetDestination var1) {
  21.       super(StylesheetDestination.access$0(var1));
  22.       this.this$1 = var1;
  23.       this.STYLENUMBER_NONE = 222;
  24.       this.additive = false;
  25.       this.characterStyle = false;
  26.       this.sectionStyle = false;
  27.       this.styleName = null;
  28.       this.number = 0;
  29.       this.basedOn = 222;
  30.       this.nextStyle = 222;
  31.       this.hidden = false;
  32.    }
  33.  
  34.    public void close() {
  35.       int var1 = this.styleName.indexOf(59);
  36.       if (var1 > 0) {
  37.          this.styleName = this.styleName.substring(0, var1);
  38.       }
  39.  
  40.       this.this$1.definedStyles.put(new Integer(this.number), this);
  41.       super.close();
  42.    }
  43.  
  44.    public boolean handleKeyword(String var1) {
  45.       if (var1.equals("additive")) {
  46.          this.additive = true;
  47.          return true;
  48.       } else if (var1.equals("shidden")) {
  49.          this.hidden = true;
  50.          return true;
  51.       } else {
  52.          return super.handleKeyword(var1);
  53.       }
  54.    }
  55.  
  56.    public boolean handleKeyword(String var1, int var2) {
  57.       if (var1.equals("s")) {
  58.          this.characterStyle = false;
  59.          this.sectionStyle = false;
  60.          this.number = var2;
  61.       } else if (var1.equals("cs")) {
  62.          this.characterStyle = true;
  63.          this.sectionStyle = false;
  64.          this.number = var2;
  65.       } else if (var1.equals("ds")) {
  66.          this.characterStyle = false;
  67.          this.sectionStyle = true;
  68.          this.number = var2;
  69.       } else if (var1.equals("sbasedon")) {
  70.          this.basedOn = var2;
  71.       } else {
  72.          if (!var1.equals("snext")) {
  73.             return super.handleKeyword(var1, var2);
  74.          }
  75.  
  76.          this.nextStyle = var2;
  77.       }
  78.  
  79.       return true;
  80.    }
  81.  
  82.    public void handleText(String var1) {
  83.       if (this.styleName != null) {
  84.          this.styleName = this.styleName + var1;
  85.       } else {
  86.          this.styleName = var1;
  87.       }
  88.  
  89.    }
  90.  
  91.    public Style realize() {
  92.       Style var1 = null;
  93.       Style var2 = null;
  94.       if (this.realizedStyle != null) {
  95.          return this.realizedStyle;
  96.       } else {
  97.          if (this.basedOn != 222) {
  98.             RTFReader$StylesheetDestination$StyleDefiningDestination var3 = (RTFReader$StylesheetDestination$StyleDefiningDestination)this.this$1.definedStyles.get(new Integer(this.basedOn));
  99.             if (var3 != null) {
  100.                var1 = var3.realize();
  101.             }
  102.          }
  103.  
  104.          this.realizedStyle = StylesheetDestination.access$0(this.this$1).target.addStyle(this.styleName, var1);
  105.          if (this.characterStyle) {
  106.             this.realizedStyle.addAttributes(((RTFReader.AttributeTrackingDestination)this).currentTextAttributes());
  107.             this.realizedStyle.addAttribute("style:type", "character");
  108.          } else if (this.sectionStyle) {
  109.             this.realizedStyle.addAttributes(((RTFReader.AttributeTrackingDestination)this).currentSectionAttributes());
  110.             this.realizedStyle.addAttribute("style:type", "section");
  111.          } else {
  112.             this.realizedStyle.addAttributes(((RTFReader.AttributeTrackingDestination)this).currentParagraphAttributes());
  113.             this.realizedStyle.addAttribute("style:type", "paragraph");
  114.          }
  115.  
  116.          if (this.nextStyle != 222) {
  117.             RTFReader$StylesheetDestination$StyleDefiningDestination var4 = (RTFReader$StylesheetDestination$StyleDefiningDestination)this.this$1.definedStyles.get(new Integer(this.nextStyle));
  118.             if (var4 != null) {
  119.                var2 = var4.realize();
  120.             }
  121.          }
  122.  
  123.          if (var2 != null) {
  124.             this.realizedStyle.addAttribute("style:nextStyle", var2);
  125.          }
  126.  
  127.          this.realizedStyle.addAttribute("style:additive", new Boolean(this.additive));
  128.          this.realizedStyle.addAttribute("style:hidden", new Boolean(this.hidden));
  129.          return this.realizedStyle;
  130.       }
  131.    }
  132. }
  133.